<template>
  <div class="deit">
    <div class="crumbs" style="margin-top:30px;">
     <el-breadcrumb separator="/">
            <el-breadcrumb-item><i class="el-icon-date"></i> 数据管理</el-breadcrumb-item>
            <el-breadcrumb-item>用户列表</el-breadcrumb-item>
        </el-breadcrumb>
        <div class="cantainer">
                    <el-table style="width: 100%;"
                    :data="userList.slice((currentPage-1)*pagesize,currentPage*pagesize)"
                    >
                        <el-table-column type="index" label="序号" width="50">    
                        </el-table-column>
                        <el-table-column label="日期" sortable prop="sunrise" width="100">    
                        </el-table-column>
                        <el-table-column label="用户姓名" sortable prop="sunset" width="120">    
                        </el-table-column>
                        <el-table-column label="邮箱" sortable prop="fx" width="100">    
                        </el-table-column>
                        <el-table-column label="地址" sortable prop="fl" width="100">    
                        </el-table-column>    
                    </el-table>
                        <el-pagination 
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="currentPage"
                            :page-sizes="[5, 10, 20, 40]"
                            :page-size="pagesize"      
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="userList.length">    
                    </el-pagination>
        </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
      return {
                currentPage:1, //初始页
                pagesize:10,    //    每页的数据
                userList: []
      }
  },
	created() {
        this.handleUserList()
    },
    methods: {
        // 初始页currentPage、初始每页数据数pagesize和数据data
        handleSizeChange: function (size) {
                this.pagesize = size;
                console.log(this.pagesize)  //每页下拉显示数据
        },
        handleCurrentChange: function(currentPage){
                this.currentPage = currentPage;
                console.log(this.currentPage)  //点击第几页
        },
        handleUserList() {
            this.$axios.get('http://t.weather.sojson.com/api/weather/city/101030100')
        .then((response) => {
          console.log(response.data.data.forecast);
					// this.userList = res.body
          //this.list = response.data.data.list;
					this.userList = response.data.data.forecast;
        }).catch((error) => {
          console.log(error);
        });
        }
    }

}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
/* .el-pagination span {
	width: 45% !important;
} */
.el-pagination {
	    white-space: initial;
}
</style>